package com.gz.springcloud.controller;

import com.alibaba.csp.sentinel.adapter.servlet.callback.UrlCleaner;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;

@Component
public class CustomUrlCleaner implements UrlCleaner {
    @Override
    public String clean(String originUrl) { //资源清洗 /member/get/1
        if(StringUtils.isBlank(originUrl)){
            return originUrl;
        }

        //如果以/member/get，那么以/member/get/*格式返回给sentinel
        //这样就不会出现每输入不同的id就出现一个新格式的请求
        if(originUrl.startsWith("/member/get")){
            return "/member/get/*";
        }
        return originUrl;
    }
}
